﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Security;
using iOak.Business.Users;
using iOak.Business.Samples;
using iOak.Domain.Directory;
using iOak.Domain.Resumes;
using iOak.Business.Resumes;

namespace iOak.Web
{
    public partial class WebForm1 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            //if ( !User.Identity.IsAuthenticated || string.IsNullOrEmpty(User.Identity.Name))
            //   FormsAuthentication.RedirectToLoginPage();

            // User.Identity.Name
            // 通过该值能够返回User对象

            var userProxy = new UserService();
            var user = userProxy.GetUserByName(User.Identity.Name);

            Response.Write("Hello,Nice to meet you! " + user.UserName);

            var company = new Company { CompanyId = Guid.Parse("bf7a1e5f-2591-428e-8165-21473a92842b"), CompanyName = "Hello Company 123 ", ContactPerson = "abc", ContactPhone = "234134", ContactEmail="kk@www.com", IsActive = true, CreatedBy = Guid.NewGuid(), CreatedOn = DateTime.Now, ModifiedBy = Guid.NewGuid(), ModifiedOn = DateTime.Now };
            var proxy = new CompanyService();

            //proxy.Create(company);
            proxy.Update(company);

            FillIndustryDropDowns();
        }

        private void FillIndustryDropDowns()
        {
            this.ddlIndustry.Items.Clear();

            var bc = new SampleService();
            var list = bc.LoadIndustries();

            foreach (PicklistValue i in list)
            {
                var item = new ListItem(i.Name, Convert.ToString(i.Value));
                item.Selected = i.Selected;

                this.ddlIndustry.Items.Add(item);
            }
        }
    }
}